package com.xiaoma.myaudience.biz.model;

import org.json.JSONException;
import org.json.JSONObject;

import android.graphics.drawable.Drawable;

public class CategoryOptionInfo extends QuickAction {
	public static final String PARAM_ID = "id";
	public static final String PARAM_TYPE = "type";
	public static final String PARAM_AREA = "area";

	public String mTypeTitle;
	public String mArea;
	
	public CategoryOptionInfo(int id, Drawable d, String title, String type) {
		super(id, d, title, type);
		// TODO Auto-generated constructor stub
	}

	public void readFromJSONObject(JSONObject o) throws JSONException {
		if (o != null) {
			if (o.has(PARAM_ID))
				mID = o.getInt(PARAM_ID);
			if (o.has(PARAM_TYPE)) {
				mTitle = o.getString(PARAM_TYPE);
				mType = PARAM_TYPE;
			} else if (o.has(PARAM_AREA)) {
				mTitle = o.getString(PARAM_AREA);
				mType = PARAM_AREA;
			}		
		}
	}

    public static CategoryOptionInfo jsonObject2CategoryOptionInfo(JSONObject o, CategoryOptionInfo info) {
        try {
            info.readFromJSONObject(o);
        } catch (JSONException e) {
        }
        return info;
    }

}
